package com.ls.x.service;

import java.util.List;

import com.ls.x.activity.beans.UserBean;
import com.ls.x.dao.UserDao;
import com.ls.x.tool.DatabaseHelper;

public class UserService implements IUserService {

	private UserDao userDao;

	public UserService(DatabaseHelper databaseHelper) {
		this.userDao = new UserDao(databaseHelper);
	}

	@Override
	public void deleteAllUser() {
		userDao.deleteAllUser();

	}

	@Override
	public List<UserBean> selectUserByUserBean(UserBean userBean) {
		return userDao.selectUserByUserBean(userBean);
	}

	@Override
	public void saveUserBean(UserBean userBean) {
		userDao.saveUserBean(userBean);

	}

	@Override
	public boolean isUserExist(String username) {
		UserBean userBean = new UserBean();
		userBean.setUsername(username);
		List<UserBean> userBeanList = userDao.selectUserByUserBean(userBean);
		if (userBeanList != null && userBeanList.size() > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public List<UserBean> getAllUserBeanList() {
		UserBean userBean = new UserBean();
		List<UserBean> userBeanList = userDao.selectUserByUserBean(userBean);
		return userBeanList;
	}

}
